package singleton;

/**
 * FileName: LazyDoubleCheckSingleton
 * Author:   周壮
 * Date:     2020/3/5 11:57
 * Description:
 */
public class LazyDoubleCheckSingleton {
    private volatile static LazyDoubleCheckSingleton lazy = null;
    private LazyDoubleCheckSingleton() {
    }
    public static LazyDoubleCheckSingleton getInstance() {
        if (lazy == null) {
            synchronized (LazyDoubleCheckSingleton.class) {
                if (lazy == null) {
                    lazy = new LazyDoubleCheckSingleton();
                    //1.分配内存给这个对象
                    // 2.初始化对象
                    // 3.设置 lazy 指向刚分配的内存地址
                }
            }
        }
        return lazy;
    }
}
